﻿using System;
using QuickDev.Common.Serialization;

namespace QuickDev.Model
{
    /// <summary>
    /// <para>MemberUser Object</para>
    /// </summary>
    [Serializable]
    public class MemberUser
    {
        #region Private Fields
        private int _userId;
        private string _loginName;
        private string _displayName;
        private string _passwordHash;
        private string _passwordSalt;
        private string _email;
        private string _phone;
        private int _status;
        private string _iPRegister;
        private string _iPLastLogin;
        private string _iPLogin;
        private DateTime _registerTime;
        private DateTime _lastLoginTime;
        private int _loginTimes;
        private DateTime _onLineTime;
        private int _permissions;
        private string _role;
        private int _vibrancy;
        #endregion

        #region Public Properties

        ///<summary>
        ///UserId
        ///</summary>
        public int UserId
        {
            get { return _userId; }
            set { _userId = value; }
        }

        ///<summary>
        ///LoginName
        ///</summary>
        public string LoginName
        {
            get { return _loginName; }
            set { _loginName = value; }
        }

        ///<summary>
        ///DisplayName
        ///</summary>
        public string DisplayName
        {
            get { return _displayName; }
            set { _displayName = value; }
        }

        ///<summary>
        ///PasswordHash
        ///</summary>
        public string PasswordHash
        {
            get { return _passwordHash; }
            set { _passwordHash = value; }
        }

        ///<summary>
        ///PasswordSalt
        ///</summary>
        public string PasswordSalt
        {
            get { return _passwordSalt; }
            set { _passwordSalt = value; }
        }

        ///<summary>
        ///Email
        ///</summary>
        public string Email
        {
            get { return _email; }
            set { _email = value; }
        }

        ///<summary>
        ///Phone
        ///</summary>
        public string Phone
        {
            get { return _phone; }
            set { _phone = value; }
        }

        ///<summary>
        ///Status
        ///</summary>
        public int Status
        {
            get { return _status; }
            set { _status = value; }
        }

        ///<summary>
        ///IPRegister
        ///</summary>
        public string IPRegister
        {
            get { return _iPRegister; }
            set { _iPRegister = value; }
        }

        ///<summary>
        ///IPLastLogin
        ///</summary>
        public string IPLastLogin
        {
            get { return _iPLastLogin; }
            set { _iPLastLogin = value; }
        }

        ///<summary>
        ///IPLogin
        ///</summary>
        public string IPLogin
        {
            get { return _iPLogin; }
            set { _iPLogin = value; }
        }

        ///<summary>
        ///RegisterTime
        ///</summary>
        public DateTime RegisterTime
        {
            get { return _registerTime; }
            set { _registerTime = value; }
        }

        ///<summary>
        ///LastLoginTime
        ///</summary>
        public DateTime LastLoginTime
        {
            get { return _lastLoginTime; }
            set { _lastLoginTime = value; }
        }

        ///<summary>
        ///LoginTimes
        ///</summary>
        public int LoginTimes
        {
            get { return _loginTimes; }
            set { _loginTimes = value; }
        }

        ///<summary>
        ///OnLineTime
        ///</summary>
        public DateTime OnLineTime
        {
            get { return _onLineTime; }
            set { _onLineTime = value; }
        }

        /// <summary>
        /// Vibrancy
        /// </summary>
        public int Vibrancy
        {
            set { _vibrancy = value; }
            get { return _vibrancy; }
        }
        /// <summary>
        /// Permissions
        /// </summary>
        public int Permissions
        {
            set { _permissions = value; }
            get { return _permissions; }
        }

        /// <summary>
        /// Role
        /// </summary>
        public string Role
        {
            set { _role = value; }
            get { return _role; }
        }
        #endregion

        #region Serialization Methods

        /// <summary>
        /// News from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        /// <returns></returns>
        public object NewFromXml( string xml )
        {
            Serializer serializer = new Serializer();
            return serializer.DeserializeObject( xml, typeof( MemberUser ).AssemblyQualifiedName );
        }

        /// <summary>
        /// Toes the XML.
        /// </summary>
        /// <returns></returns>
        public string ToXml()
        {
            Serializer serializer = new Serializer();
            return serializer.SerializeObject( this, typeof( MemberUser ) );
        }

        #endregion
    }
}